package com.yl.widget;

import android.content.Context;
import android.graphics.Bitmap;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.yl.order.R;

public class MenuItem extends LinearLayout{

	private Context mContext = null;
	private TextView mText = null;
	private ImageView mImage = null;
	
	public MenuItem(Context context) {
		super(context);
		init(context);
	}
	
	public MenuItem(Context context, AttributeSet attrs) {
		super(context, attrs);
		init(context);
	}
	
	private void init(Context context) {
		mContext = context;
		LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View main = inflater.inflate(R.layout.menu_item, this);
		mText = (TextView)main.findViewById(R.id.menu_item_text);
	}

	public void setText(int resid) {
		if (mText != null) {
			mText.setText(resid);
		}
	}
	
	public void setText(String s) {
		if (mText != null) {
			mText.setText(s);
		}
	}
	
	public void setImage(int resid) {
		if (mImage != null) {
			mImage.setImageResource(resid);
		}
	}
	
	public void setImage(Bitmap b) {
		if (mImage != null) {
			mImage.setImageBitmap(b);
		}
	}
}
